package com.example.george.myapplication;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.LinearLayout;
import android.widget.TextView;

import lv.id.amsterjanis.bernu_spelite.R;


public class MyActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my);
        populateTiles(4, 3);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.my, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    public void populateTiles(int rows, int cols) {
        // clear all elements
        LinearLayout linearLayout = (LinearLayout) findViewById(R.id.main_container);
        linearLayout.removeAllViews();

        for (int i = 0; i < rows; i++) {
            for (int j = 0; j < cols; j++) {
                LinearLayout lin = new LinearLayout(this);
                lin.setOrientation(LinearLayout.HORIZONTAL);
                lin.setDividerPadding(20);
                lin.se
                Tile tile = new Tile(i * j, "aaaaa", Color.BLUE);
                TextView tv = new TextView(this);
                tv.setText(tile.getText());
                lin.setBackgroundColor(tile.getColor());
                lin.addView(tv);
                linearLayout.addView(lin);
            }
        }
    }
}
